package com.ssy.lingxi.purchase.entity.tender;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonManagedReference;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * 投标物料表
 * @author jw.chen
 * @version 2.0.0
 * @date 2021/3/1
 */
@Getter
@Setter
@Entity
@Table(schema = "public", name = "purchase_submit_tender_materiel")
public class SubmitTenderMateriel implements Serializable {
    private static final long serialVersionUID = 9051397867789285965L;
    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="submit_tender_materiel_seq")
    @SequenceGenerator(sequenceName="purchase_submit_tender_materiel_seq", name="submit_tender_materiel_seq",allocationSize = 1)
    private Long id;

    /**
     * 投标信息
     */
    @JsonIgnore
    @ManyToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="submitTenderId",referencedColumnName = "id")
    private SubmitTender submitTender;

    /**
     * 招标物料
     */
    @OneToOne(cascade = {CascadeType.PERSIST})
    @JoinColumn(name="inviteTenderMaterielId",referencedColumnName = "id")
    private InviteTenderMateriel inviteTenderMateriel;

    /**
     * 关联商品id
     */
    @Column(columnDefinition = "int8")
    private Long commodityId;

    /**
     * 关联商品skuId
     */
    @Column(columnDefinition = "int8")
    private Long commoditySkuId;

    /**
     * 是否含税
     */
    @Column(columnDefinition = "boolean", nullable = false)
    private Boolean isTax = true;

    /**
     * 税率
     */
    @Column(columnDefinition = "decimal", nullable = false)
    private Double taxRate;

    /**
     * 单价
     */
    @Column(columnDefinition = "decimal", nullable = false)
    private Double price;

    /**
     * 附件
     */
    @JsonManagedReference
    @OneToMany(mappedBy = "submitTenderMateriel", cascade={CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE})
    private List<SubmitTenderMaterielFile> file;

    /**
     * 是否授标
     */
    @Column(columnDefinition = "boolean")
    private Boolean isAwardTender;

    /**
     * 授标比例
     */
    @Column(columnDefinition = "decimal")
    private Double awardTenderRatio;
}
